package my.graduation.controller.admin;

import my.graduation.dto.DepartInfoDto;
import my.graduation.entity.Department;
import my.graduation.result.Result;
import my.graduation.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: RavenLyn
 * @Date: 2024-12-09
 */
@RestController
@RequestMapping("/admin/depart")
public class AdmDepartmentController {

    @Autowired
    private DepartmentService departmentService;

    /**
     * 获取科室信息
     * @return
     */
    @GetMapping
    public Result<List<Department>> list(){
        return Result.success(departmentService.list());
    }

    /**
     * 条件获取科室信息
     * @param dto
     * @return
     */
    @PostMapping("/con")
    public Result<List<Department>> list(@RequestBody DepartInfoDto dto){
        return departmentService.getListByCon(dto);
    }

    /**
     * 新增科室信息
     * @return
     */
    @PostMapping
    public Result add(@RequestBody DepartInfoDto dto){
        return departmentService.add(dto);
    }

    /**
     * 修改科室信息
     * @return
     */
    @PutMapping
    public Result update(@RequestBody DepartInfoDto dto){
        return departmentService.update(dto);
    }

    /**
     * 删除科室信息
     * @return
     */
    @DeleteMapping
    public Result delete(@RequestBody DepartInfoDto dto){
        return departmentService.delete(dto);
    }
}
